public class Test1 {
    //leetcode 相同的树
    //https://leetcode.cn/problems/same-tree/description/?envType=problem-list-v2&envId=tree
    public boolean isSameTree(TreeNode p, TreeNode q) {
        if ((p == null && q != null) || q == null && p != null) return false;
        if (p == null && q == null) return true;
        if (p.val != q.val) return false;
        return isSameTree(p.left,q.left) && isSameTree(p.right,q.right);
    }
}
